//
//  MoreFunctionView.m
//  ChangJia
//
//  Created by 张育铭 on 16/9/14.
//  Copyright © 2016年 Zhangyuming. All rights reserved.
//

#import "MoreFunctionView.h"
#import <UIKit/UIKit.h>
#import <SDAutoLayout/SDAutoLayout.h>

@implementation MoreFunctionView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {

        [self addSubview:self.praiseBtn];
        [self addSubview:self.messageBtn];
        
        self.praiseBtn.sd_layout
        .topSpaceToView (self, 0)
        .leftSpaceToView(self, 10)
        .widthIs(50)
        .heightIs(25);
        
        self.messageBtn.sd_layout
        .topEqualToView(self.praiseBtn)
        .leftSpaceToView(self.praiseBtn,0)
        .widthIs(50)
        .heightIs(25);
    }
    return self;
}

- (void)btnClick:(UIButton*)sender {
    _shareAndpraiseBtnBlock(sender.tag);
}

- (UIButton *)praiseBtn {
    if (_praiseBtn == nil) {
        _praiseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _praiseBtn.tag = 1002;
        [_praiseBtn setImage: [UIImage imageNamed:@"bbs-nice-lt"] forState:(UIControlStateNormal)];
        [_praiseBtn setImage: [UIImage imageNamed:@"bbs-nice-cg-lt"] forState:UIControlStateSelected];
        [_praiseBtn addTarget:self action:@selector(btnClick:) forControlEvents:(UIControlEventTouchUpInside)];
        _praiseBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, -5);
        [_praiseBtn setTitleColor:[UIColor grayColor] forState:(UIControlStateNormal)];
        _praiseBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    }
    return _praiseBtn;
}

- (UIButton *)messageBtn {
    if (_messageBtn == nil) {
        _messageBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _messageBtn.tag = 1003;
        [_messageBtn setImage: [UIImage imageNamed:@"main-chat"] forState:(UIControlStateNormal)];
        _messageBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, -10);
        [_messageBtn setTitleColor:[UIColor grayColor] forState:(UIControlStateNormal)];
        _messageBtn.titleLabel.font = [UIFont systemFontOfSize:13];
        [_messageBtn addTarget:self action:@selector(btnClick:) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _messageBtn;
}

@end
